<?php
include $_SERVER['DOCUMENT_ROOT'].'/fr/include/init.php';
include $_SERVER['DOCUMENT_ROOT'].'/fr/include/require_login.php'; 
if($_SESSION['logged'] == 0){
	header("location: /fr/inscription.php?error_msg=$error_msg" );
} 
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<? include $_SERVER['DOCUMENT_ROOT'].'/fr/include/meta.php'; ?>
	<meta name="description" content="Herbes de Chine : Mon compte" />
	<meta name="keywords" content="Herbes de chine, compte,suivi,mon compte,profil,historique,historique des commandes,commandes en cours" />
	<title>Herbes de Chine : Mon compte</title>
	<link href="/fr/css/common.css" rel="stylesheet" type="text/css" />
	<link href="/fr/css/inside.css" rel="stylesheet" type="text/css" />
	<script language="javascript" type="text/javascript" src="/fr/js/static.js"></script>
</head>
<body>
	<? include $_SERVER['DOCUMENT_ROOT'].'/fr/include/header.php'; ?>
    <div id="tools">
    	<table>
        	<tr>
            	<td id="chemin"><a href="/fr/index.html">Accueil</a> > Mon compte</td>
                <td id="search">
					<? include $_SERVER['DOCUMENT_ROOT'].'/fr/include/displaytoolbar.php'; ?>

				</td>
            </tr>
        </table>
    </div>
	<!-- // Mes Coordonnées //-->
	<h1>Mes informations personnelles</h1>
	<table class="widescreen">
		<tr class="top"><td colspan="2"></td></tr>
		<tr class="middle"><td class="content">
		<div class="double">
			<table class="left">
				<tr>
					<td colspan="2"><h2>Mon adresse de facturation</h2></td>
				</tr>
				<tr class="ligne">
					<td width="20%"><strong>Adresse</strong></td>
					<td>
						<?
						echo $_SESSION['user_title']." ".$_SESSION['adr_firstname']." ".$_SESSION['adr_lastname']."<br/>";
						if($_SESSION['adr_company']){
							echo $_SESSION['adr_company']."<br/>";
						}
						echo $_SESSION['adr_address']."<br/>";
						echo $_SESSION['adr_zipcode']." ".$_SESSION['adr_city']."<br/>";
						echo $_SESSION['adr_country']."<br/>";
						?>
					</td>
				</tr>
				<tr><td colspan="2">&nbsp;</td></tr>
				<tr class="ligne">
					<td><strong>Téléphone</strong></td>
					<td><? echo $_SESSION['adr_phone'] ?></td>
				</tr>
				<? if($_SESSION['adr_cellphone']!=""){ ?>
				<tr class="ligne">
					<td><strong>Portable</strong></td>
					<td><? echo $_SESSION['adr_cellphone'] ?></td>
				</tr>
				<? } ?>
				<tr><td colspan="6">&nbsp;</td></tr>
			</table>
			<table class="right">
				<tr>
					<td colspan="2"><h2>Mon adresse de livraison</h2></td>
				</tr>
				<tr class="ligne">
					<td width="20%"><strong>Adresse</strong></td>
					<td>
						<?
						echo $_SESSION['user_title']." ".$_SESSION['liv_firstname']." ".$_SESSION['liv_lastname']."<br/>";
						if($_SESSION['liv_company']){
							echo $_SESSION['liv_company']."<br/>";
						}
						echo $_SESSION['liv_address']."<br/>";
						echo $_SESSION['liv_zipcode']." ".$_SESSION['liv_city']."<br/>";
						echo $_SESSION['liv_country']."<br/>";
						?>
					</td>
				</tr>
				<tr><td colspan="2">&nbsp;</td></tr>
				<tr class="ligne">
					<td><strong>Téléphone</strong></td>
					<td><? echo $_SESSION['liv_phone'] ?></td>
				</tr>
				<? if($_SESSION['liv_cellphone']!=""){ ?>
				<tr class="ligne">
					<td><strong>Portable</strong></td>
					<td><? echo $_SESSION['liv_cellphone'] ?></td>
				</tr>
				<? } ?>
				<tr><td colspan="6">&nbsp;</td></tr>
			</table>
			<table class="clear">
				<tr><td colspan="2">&nbsp;</td></tr>
				<tr>
					<td colspan="2" class="bar"><img src="/img/common/lightgreybar.gif" alt="" /></td>
				</tr>
				<tr>
					<td></td>
					<td colspan="2" class="addcart aright"><a href="/fr/moncompte/profil.php?cal=com"><img src="/img/common/modifier_btn.gif" alt="Modifier" /></a></td>
				</tr>
				<tr><td colspan="2">&nbsp;</td></tr>
			</table>
		</div>
		</td></tr>
		<tr class="bottom"><td colspan="2"></td></tr>
	</table><br />
	<!-- // Ma commande //-->
	<h1>Mes commandes</h1>
	<?
	$q1 = mysql_query("SELECT * FROM `command` WHERE user_id = '".$_SESSION['user_id']."' AND `com_statut` <> 'terminée' AND `com_statut` <> 'annulée' ORDER BY `com_date` DESC");
	$c = @mysql_num_rows($q1);
	if($c>0) {?>
	<table class="widescreen">
		<tr class="top"><td colspan="2"></td></tr>
		<tr class="middle"><td class="content">
			<table>
				<tr>
					<td colspan="3"><h2>Mes commandes en cours</h2></td>
				</tr>
				<tr class="title">
					<td width="30%">Date</td>
					<td width="30%">Statut</td>
					<td width="40%">Prix de la commande</td>
				</tr>
				<?
				$q1a = mysql_query("SELECT * FROM `command` WHERE user_id = '".$_SESSION['user_id']."' AND (`com_statut` <> 'terminée' AND `com_statut` <> 'annulée') ORDER BY `com_date` DESC");
				while($r1 = mysql_fetch_array($q1a)){ 
				$date0 = split(" ", $r1['com_date']);
				$date1 = split("-", $date0[0]);
				$hour1 = split(":", $date0[1]);
				$date = date("d/m/Y", mktime(0, 0, 0, $date1[1], $date1[2], $date1[0]))." - ".$date1[0]."/".$date1[1]."/".$date1[20];
				$hour = date("H:i", mktime($hour1[0], $hour1[1], $hour1[2], $date1[2], $date1[1], $date1[0]));
				?>
				<tr class="ligne">
					<td><a href="/fr/moncompte/historique.php?cmd=<? echo $r1['com_id']; ?>"><? echo "Commande du ".$date." à ".$hour; ?></a></td>
					<td><? echo $r1['com_statut']; ?></td>
					<td><? echo $r1['com_price']." €"; ?></td>
				</tr>
				<? } ?>
				<tr><td colspan="3">&nbsp;</td></tr>
				<tr><td colspan="3" class="bar"><img src="/img/common/lightgreybar.gif" alt="" /></td></tr>
				<tr><td colspan="3">&nbsp;</td></tr>
			</table>
			<!--<div class="info">
				<input id="check1" type="checkbox" /><label for="check1">Cochez cette case si vous désirez vous faire livrer à une autre adresse.</label><br />
			</div>-->
		</td></tr>
		<tr class="bottom"><td colspan="2"></td></tr>
	</table><br />
	<? } ?>
	<table class="widescreen">
		<tr class="top"><td colspan="2"></td></tr>
	    <tr class="middle"><td class="content">
			<table>
				<tr>
					<td colspan="3"><h2>L'historique de mes commandes</h2></td>
				</tr>
				<? 
				$q3 = mysql_query("SELECT * FROM `command` WHERE user_id = '".$_SESSION['user_id']."' AND (`com_statut` = 'terminée' OR `com_statut` = 'annulée') ORDER BY `com_date` DESC");
				$c3 = @mysql_num_rows($q3);
				if($c3<=0) {?>
					<tr><td colspan="3">Vous n'avez encore aucune commande finalisée.</td></tr>
				<? } else if($c3<=0) {?>
					<tr><td colspan="3">Vous n'avez effectué aucune commande.</td></tr>
				<? } else { ?>
					<tr class="title">
						<td width="30%">Date</td>
						<td width="30%">Statut</td>
						<td width="40%">Prix de la commande</td>
					</tr>
					<?
					while($r1 = mysql_fetch_array($q3)){ 
					$date0 = split(" ", $r1['com_date']);
					$date1 = split("-", $date0[0]);
					$hour1 = split(":", $date0[1]);
					//$date = date("d/m/Y", mktime($hour1[0], $hour1[1], $hour1[2], $date1[2], $date1[1], $date1[0]))." - ".$date1[2]."/".$date1[1]."/".$date1[0];
					$date = $date1[2]."/".$date1[1]."/".$date1[0];
					//$hour = date("H:i", mktime($hour1[0], $hour1[1], $hour1[2], $date1[2], $date1[1], $date1[0]))." - ".$hour1[0]."/".$hour1[1]."/".$hour1[2];
					$hour = $hour1[0].":".$hour1[1];
					?>
					<tr class="ligne">
						<td><a href="/fr/moncompte/historique.php?cmd=<? echo $r1['com_id']; ?>"><? echo "Commande du ".$date." à ".$hour; ?></a></td>
						<td><? echo $r1['com_statut']; ?></td>
						<td><? echo $r1['com_price']." €"; ?></td>
					</tr>
					<? } ?>
				<? } ?>
				<tr><td colspan="3">&nbsp;</td></tr>
				<tr><td colspan="3" class="bar"><img src="/img/common/lightgreybar.gif" alt="" /></td></tr>
				<tr><td colspan="3">&nbsp;</td></tr>
			</table>
		</td></tr>
		<tr class="bottom"><td colspan="2"></td></tr>
	</table>
	<? include $_SERVER['DOCUMENT_ROOT'].'/fr/include/footer.php'; ?>
</body>
</html>
